package control.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * No throw aspect
 *
 * @description:
 * @author: cyj
 * @date 2020 -10-28 15:15:17
 */
@Aspect
@Component
@Order(-1)
public class NoThrowAspect {

    /**
     * No throw aspect
     */
    @Pointcut(value = "@annotation(base.standard.exception.NoThrow)")
    public void noThrowAspect() {
    }

    /**
     * Try catch object
     *
     * @param point point
     * @return the object
     * @description:
     */
    @Around("noThrowAspect()")
    public Object tryCatch(ProceedingJoinPoint point) {
        try {
            return point.proceed();
        } catch (Throwable throwable) {
            throwable.printStackTrace();
            return null;
        }
    }
}
